import { reactive } from "vue";
import { getListApi as warehouseCodeApi } from "@/api/configCenter/warehouseCode";
import { getCustomerSelectList } from "@/api/managementCenter/customerManagement";
import { getUserByPositionApi, getAllCompanyApi } from "@/api/managementCenter/departmentPersonnel";

export const searchItemList: Array<SuperSearch.SearchItem> = [
  {
    type: "input",
    label: "头程运单号",
    keyName: "waybillNumList",
    placeholder: "支持批量(空格/逗号隔开)"
  },
  {
    type: "input",
    label: "海外仓运单号",
    keyName: "warehouseBillNumList",
    placeholder: "支持批量(空格/逗号隔开)"
  },
  {
    type: "input",
    label: "FBA运单号",
    keyName: "fbaNumberList",
    placeholder: "支持批量(空格/逗号隔开)"
  },
  {
    type: "input",
    label: "转单号",
    keyName: "transferOrderNumberList",
    placeholder: "支持批量(空格/逗号隔开)"
  },
  reactive<SuperSearch.SearchItem>({
    type: "select",
    label: "仓库代码",
    keyName: "warehouseCodeList",
    optionsRequest: warehouseCodeApi,
    optReqParams: { status: 1, pageNum: 1, pageSize: 9999999, total: 0 },
    optReqCb: (res: Base.GeneraDataType, row: SuperSearch.SearchItem) => {
      const { code, data } = res;
      if (code === 200) {
        row.options = data.records || [];
      }
    },
    attrs: {
      mode: "multiple"
    },
    optConfig: {
      label: "warehouseCode",
      value: "warehouseCode"
    },
    options: []
  }),
  reactive<SuperSearch.SearchItem>({
    type: "select",
    label: "客户简称",
    keyName: "customerIdList",
    optionsRequest: getCustomerSelectList,
    optReqParams: { isFilterChild: 0 },
    optReqCb: (res: Base.GeneraDataType, row: SuperSearch.SearchItem) => {
      const { code, data } = res;
      if (code === 200) {
        row.options = data || [];
      }
    },
    attrs: {
      mode: "multiple"
    },
    optConfig: {
      label: "shortName",
      value: "id"
    },
    options: []
  }),
  reactive<SuperSearch.SearchItem>({
    type: "select",
    label: "经营单位",
    keyName: "companyIdList",
    optionsRequest: getAllCompanyApi,
    optReqParams: { status: 1, pageNum: 1, pageSize: 9999999, total: 0 },
    optReqCb: (res: Base.GeneraDataType, row: SuperSearch.SearchItem) => {
      const { code, data } = res;
      if (code === 200) {
        row.options = data || [];
      }
    },
    attrs: {
      mode: "multiple"
    },
    optConfig: {
      label: "name",
      value: "id"
    },
    options: []
  }),
  {
    type: "input",
    label: "邮编",
    keyName: "zipCode",
    placeholder: "请输入邮编"
  },
  reactive<SuperSearch.SearchItem>({
    type: "select",
    label: "业务员",
    keyName: "bizIdList",
    optionsRequest: getUserByPositionApi,
    optReqParams: { position: "4", status: 1, pageNum: 1, pageSize: 9999999, total: 0 },
    optReqCb: (res: Base.GeneraDataType, row: SuperSearch.SearchItem) => {
      const { code, data } = res;
      if (code === 200) {
        row.options = data.records || [];
      }
    },
    attrs: {
      mode: "multiple"
    },
    optConfig: {
      label: "username",
      value: "id"
    },
    options: []
  }),
  reactive<SuperSearch.SearchItem>({
    type: "select",
    label: "跟单员",
    keyName: "followIdList",
    optionsRequest: getUserByPositionApi,
    optReqParams: { position: "5", status: 1, pageNum: 1, pageSize: 9999999, total: 0 },
    optReqCb: (res: Base.GeneraDataType, row: SuperSearch.SearchItem) => {
      const { code, data } = res;
      if (code === 200) {
        row.options = data.records || [];
      }
    },
    attrs: {
      mode: "multiple"
    },
    optConfig: {
      label: "username",
      value: "id"
    },
    options: []
  })
];

export const tableColumnMap: Base.GeneraDataType<Array<SuperTable.TableCoulmnItem | SuperTable.NestTableColumnItem>> = {
  "0": [
    {
      type: "checkbox",
      field: "checkbox",
      minWidth: "50"
    },
    {
      field: "waybillNum",
      title: "头程运单号",
      minWidth: "150"
    },
    {
      field: "fbaNumber",
      title: "FBA单号",
      minWidth: "120"
    },
    {
      field: "customerName",
      title: "客户简称",
      minWidth: "120"
    },
    {
      field: "companyName",
      title: "客户名称",
      minWidth: "120"
    },
    {
      field: "channelName",
      title: "预报渠道",
      minWidth: "120"
    },
    {
      field: "warehouseCode",
      title: "仓库代码",
      minWidth: "120"
    },
    {
      field: "surplusItemNumber",
      title: "剩余件数",
      minWidth: "120"
    },
    {
      field: "surplusSquaresNumber",
      title: "(剩余件)总方数",
      minWidth: "120"
    },
    {
      field: "bizName",
      title: "业务员",
      minWidth: "120"
    },
    {
      field: "followName",
      title: "跟单员",
      minWidth: "120"
    }
  ],
  "1": [
    {
      type: "checkbox",
      field: "checkbox",
      minWidth: "50"
    },
    {
      field: "warehouseBillNum",
      title: "海外仓运单号",
      minWidth: "230",
      renderSlot: "warehouseBillNum"
    },
    {
      field: "waybillNum",
      title: "头程运单号",
      minWidth: "150"
    },
    {
      field: "fbaNumber",
      title: "FBA单号",
      minWidth: "120"
    },
    {
      field: "pushSuccessFlag",
      title: "推单状态",
      minWidth: "120",
      renderSlot: "pushSuccessFlag"
    },
    {
      field: "pushSuccessResult",
      title: "推单结果",
      minWidth: "120"
    },
    {
      field: "customerName",
      title: "客户简称",
      minWidth: "120"
    },
    {
      field: "countryRegionName",
      title: "目的地",
      minWidth: "120"
    },
    {
      field: "warehouseCode",
      title: "仓库代码",
      minWidth: "120"
    },
    {
      field: "agentChannelName",
      title: "代理渠道",
      minWidth: "120"
    },
    {
      field: "itemNumber",
      title: "件数",
      minWidth: "120"
    },
    {
      field: "actualWeight",
      title: "重量",
      minWidth: "120"
    },
    {
      field: "zipCode",
      title: "邮编",
      minWidth: "120"
    },
    {
      field: "bizName",
      title: "业务员",
      minWidth: "120"
    },
    {
      field: "followName",
      title: "跟单员",
      minWidth: "120"
    }
  ],
  "2": [
    {
      type: "checkbox",
      field: "checkbox",
      minWidth: "50"
    },
    {
      field: "warehouseBillNum",
      title: "海外仓运单号",
      minWidth: "230",
      renderSlot: "warehouseBillNum"
    },
    {
      field: "waybillNum",
      title: "头程运单号",
      minWidth: "150"
    },
    {
      field: "fbaNumber",
      title: "FBA单号",
      minWidth: "120"
    },
    {
      field: "pushSuccessFlag",
      title: "推单状态",
      minWidth: "120",
      renderSlot: "pushSuccessFlag"
    },
    {
      field: "pushSuccessResult",
      title: "推单结果",
      minWidth: "120"
    },
    {
      field: "customerName",
      title: "客户简称",
      minWidth: "120"
    },
    {
      field: "countryRegionName",
      title: "目的地",
      minWidth: "120"
    },

    {
      field: "warehouseCode",
      title: "仓库代码",
      minWidth: "120"
    },
    {
      field: "agentChannelName",
      title: "代理渠道",
      minWidth: "120"
    },
    {
      field: "itemNumber",
      title: "件数",
      minWidth: "120"
    },
    {
      field: "actualWeight",
      title: "重量",
      minWidth: "120"
    },
    {
      field: "zipCode",
      title: "邮编",
      minWidth: "120"
    },
    {
      field: "bizName",
      title: "业务员",
      minWidth: "120"
    },
    {
      field: "followName",
      title: "跟单员",
      minWidth: "120"
    }
  ],
  "3": [
    {
      type: "checkbox",
      field: "checkbox",
      minWidth: "50"
    },
    {
      field: "warehouseBillNum",
      title: "海外仓运单号",
      minWidth: "230",
      renderSlot: "warehouseBillNum"
    },
    {
      field: "waybillNum",
      title: "头程运单号",
      minWidth: "150"
    },
    {
      field: "fbaNumber",
      title: "FBA单号",
      minWidth: "120"
    },
    {
      field: "pushSuccessFlag",
      title: "推单状态",
      minWidth: "120",
      renderSlot: "pushSuccessFlag"
    },
    {
      field: "pushSuccessResult",
      title: "推单结果",
      minWidth: "120"
    },
    {
      field: "customerName",
      title: "客户简称",
      minWidth: "120"
    },
    {
      field: "countryRegionName",
      title: "目的地",
      minWidth: "120"
    },
    {
      field: "warehouseCode",
      title: "仓库代码",
      minWidth: "120"
    },
    {
      field: "agentChannelName",
      title: "代理渠道",
      minWidth: "120"
    },
    {
      field: "itemNumber",
      title: "件数",
      minWidth: "120"
    },
    {
      field: "actualWeight",
      title: "重量",
      minWidth: "120"
    },
    {
      field: "zipCode",
      title: "邮编",
      minWidth: "120"
    },
    {
      field: "bizName",
      title: "业务员",
      minWidth: "120"
    },
    {
      field: "followName",
      title: "跟单员",
      minWidth: "120"
    }
  ],
  "4": [
    {
      type: "checkbox",
      field: "checkbox",
      minWidth: "50"
    },
    {
      field: "warehouseBillNum",
      title: "海外仓运单号",
      minWidth: "230",
      renderSlot: "warehouseBillNum"
    },
    {
      field: "waybillNum",
      title: "头程运单号",
      minWidth: "150"
    },
    {
      field: "fbaNumber",
      title: "FBA单号",
      minWidth: "120"
    },
    {
      field: "pushSuccessFlag",
      title: "推单状态",
      minWidth: "120",
      renderSlot: "pushSuccessFlag"
    },
    {
      field: "pushSuccessResult",
      title: "推单结果",
      minWidth: "120"
    },
    {
      field: "customerName",
      title: "客户简称",
      minWidth: "120"
    },
    {
      field: "countryRegionName",
      title: "目的地",
      minWidth: "120"
    },
    {
      field: "warehouseCode",
      title: "仓库代码",
      minWidth: "120"
    },
    {
      field: "agentChannelName",
      title: "代理渠道",
      minWidth: "120"
    },
    {
      field: "itemNumber",
      title: "件数",
      minWidth: "120"
    },
    {
      field: "actualWeight",
      title: "重量",
      minWidth: "120"
    },
    {
      field: "zipCode",
      title: "邮编",
      minWidth: "120"
    },
    {
      field: "bizName",
      title: "业务员",
      minWidth: "120"
    },
    {
      field: "followName",
      title: "跟单员",
      minWidth: "120"
    }
  ]
};
